package com.dingpeikeji.quickdeer.modules.rentproduct.service;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dingpeikeji.quickdeer.core.common.persistence.Page;
import com.dingpeikeji.quickdeer.core.common.service.CrudService;
import com.dingpeikeji.quickdeer.core.modules.sys.utils.UserUtils;
import com.dingpeikeji.quickdeer.modules.rentproduct.dao.TOfficeCreditDao;
import com.dingpeikeji.quickdeer.modules.rentproduct.entity.TOfficeCredit;

/**
 * 合作伙伴信用月额度Service
 * @author wuhao
 * @version 2016-08-08
 */
@Service
@Transactional(readOnly = true)
public class TOfficeCreditService extends CrudService<TOfficeCreditDao, TOfficeCredit> {

	public TOfficeCredit get(String creditid) {
		return super.get(creditid);
	}
	
	public List<TOfficeCredit> findList(TOfficeCredit tOfficeCredit) {
		return super.findList(tOfficeCredit);
	}
	
	public Page<TOfficeCredit> findPage(Page<TOfficeCredit> page, TOfficeCredit tOfficeCredit) {
		return super.findPage(page, tOfficeCredit);
	}
	
	@Transactional(readOnly = false)
	public void save(TOfficeCredit tOfficeCredit) {
		if(tOfficeCredit.getCreditid() == null) {
			tOfficeCredit.setCreateBy(UserUtils.getUser());
			tOfficeCredit.setCreateDate(new Date());
			dao.insert(tOfficeCredit);
		} else {
			dao.update(tOfficeCredit);
		}
	}
	
	public List<TOfficeCredit> findTotalCreditList(TOfficeCredit tOfficeCredit){
		return dao.getTotalCredit(tOfficeCredit);
	}
	
	@Transactional(readOnly = false)
	public void delete(TOfficeCredit tOfficeCredit) {
		super.delete(tOfficeCredit);
	}
	
}